/**
 * 
 */
package jvs.peer.io;

import java.io.IOException;
import java.io.InputStream;

/**
 * @author qiangli
 *
 */
public class PooledInputStream extends InputStream {
	private InputStream in;

	private boolean closed;
	
	public PooledInputStream(InputStream in) {
		super();
		this.in = in;
	}

	public int available() throws IOException {
		return in.available();
	}

	public void close() throws IOException {
		closed = true;
	}

	public void mark(int readlimit) {
		in.mark(readlimit);
	}

	public boolean markSupported() {
		return in.markSupported();
	}

	public int read() throws IOException {
		return in.read();
	}

	public int read(byte[] buffer, int offset, int length) throws IOException {
		return in.read(buffer, offset, length);
	}

	public int read(byte[] b) throws IOException {
		return in.read(b);
	}

	public void reset() throws IOException {
		in.reset();
	}

	public long skip(long byteCount) throws IOException {
		return in.skip(byteCount);
	}
	
	public void destroy() {
		closed = true;
		if (in == null) {
			return;
		}
		try {
			in.close();
		} catch (IOException e) {
			e.printStackTrace();
		}
		in = null;
	}

	public boolean isClosed() {
		return closed;
	}
}
